#include <iostream>
#include <string>
#include <cstddef>

using namespace std;

class MyStruct
{
public:
    int a;
    double b;
};

int func(double d)
{
    cout << "d = " << d << endl;
    return 0;
}

void test(MyStruct *p)
{
    // 定义函数指针的三种方式：

    // typedef int (FUNC)(double);      // (1)  先定义函数类型
    // FUNC *pFunc = func;

    // typedef int (*FUNC)(double);     // (2)  先定义函数指针类型
    // FUNC pFunc = func;

    int (*pFunc)(double) = func;        // (3)  直接定义函数指针
    pFunc(3.2);

}

// 测试指针步长
void test1()
{
    int *p = 0;
    cout << "p = " << p << endl;
    cout << "p + 1= " << p + 1 << endl;
    double *p1 = 0;
    cout << "p1 = " << p1 << endl;
    cout << "p1 + 1 = " << p1 + 1 << endl;
}


int main(int argc, char **argv)
{
    MyStruct mystruct = {10, 2.1};
    MyStruct *p = &mystruct;
    int a = offsetof(MyStruct, b);
    cout << a << endl;
    // test(p);
    test1();
    return 0;
}